package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Account;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface AccountMapper extends BaseMapper<Account> {

    /**
     *
     * @param userAccount
     * @param money
     * @return
     */
    @Update("update user_account set amount=amount-#{amount} where userAccount=#{userAccount}")
    int setMoneyByUserName(@Param("userAccount") String userAccount, @Param("amount") Integer money);

    /**
     * 根据用户名查对象
     * @param userAccount
     * @return
     */
    @Select("select * from user_account where userAccount = #{userAccount}")
    Account ByName(String userAccount);
}
